package org.birrap.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;


@Entity
@Table(name = "OFERTAS_T")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "OfertasT.findAll", query = "SELECT o FROM OfertasT o"),
    @NamedQuery(name = "OfertasT.findByIdOferta", query = "SELECT o FROM OfertasT o WHERE o.idOferta = :idOferta"),
    @NamedQuery(name = "OfertasT.findByDescripcion", query = "SELECT o FROM OfertasT o WHERE o.descripcion = :descripcion"),
    @NamedQuery(name = "OfertasT.removeById",query = "DELETE FROM OfertasT o WHERE o.idOferta = :idOferta"),
})
@SequenceGenerator (name="SEQ_OFERTA_T" , sequenceName ="SEQ_OFERTA_T" , allocationSize = 1)

public class OfertasT implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID_OFERTA")
    @GeneratedValue (strategy = GenerationType.SEQUENCE, generator = "SEQ_OFERTA_T")
    private Integer idOferta;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 150)
    @Column(name = "DESCRIPCION")
    private String descripcion;
    @ManyToMany(mappedBy = "ofertasTCollection")
    private Collection<BaresT> baresTCollection;

    public OfertasT() {
    }

    public OfertasT(Integer idOferta) {
        this.idOferta = idOferta;
    }

    public OfertasT(Integer idOferta, String descripcion) {
        this.idOferta = idOferta;
        this.descripcion = descripcion;
    }

    public Integer getIdOferta() {
        return idOferta;
    }

    public void setIdOferta(Integer idOferta) {
        this.idOferta = idOferta;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    @XmlTransient
    public Collection<BaresT> getBaresTCollection() {
        return baresTCollection;
    }

    public void setBaresTCollection(Collection<BaresT> baresTCollection) {
        this.baresTCollection = baresTCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idOferta != null ? idOferta.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof OfertasT)) {
            return false;
        }
        OfertasT other = (OfertasT) object;
        if ((this.idOferta == null && other.idOferta != null) || (this.idOferta != null && !this.idOferta.equals(other.idOferta))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.birrap.ejb.OfertasT[ idOferta=" + idOferta + " ]";
    }
    
}
